package com.aptech.oas.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class FileDownloadAction extends ActionSupport {

	private String fileName="dos命令操作.docx";

	public InputStream getDownloadFile() throws FileNotFoundException {
		File file = new File("g:/attachment/test1/dos命令操作.docx");
		InputStream is = new FileInputStream(file);
		try {
			fileName=new String(fileName.getBytes("gbk"),"ISO8859-1");
//			ServletActionContext.getResponse().setHeader("Content-Disposition","attachment;fileName="+java.net.URLEncoder.encode(fileName, "UTF-8"));
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return is;
	}

	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

}
